<%--
  Created by IntelliJ IDEA.
  User: 14811
  Date: 2022-5-1
  Time: 9:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/common.jsp"%>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>东东旅游网-登录</title>
    <link rel="stylesheet" type="text/css" href="../../css/common.css">
    <link rel="stylesheet" type="text/css" href="../../css/login.css">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!--导入angularJS文件-->
    <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
    <!--导入jquery-->
</head>
<script>
    function userLogin() {
        $.ajax({
            url : "<%=path%>/loginController/login",
            dataType : "json",
            type : "post",
            data : $("#form_login").serialize(),
            async : true,
            success : function (data) {
                if (data == 0) {
                    var myDialog = dialog({
                        content : "登录成功"
                    })

                    myDialog.show();
                    setTimeout(function(){
                        myDialog.close();
                        window.location.replace("<%=path%>/pageController/toIndex")
                    }, 2000)

                } else if (data == 1) {
                    toastr.error("账号不村在");
                } else if (data == 2) {
                    toastr.error("账号密码为空");
                } else if (data == 3) {
                    toastr.error("账号已经被冻结");
                } else if (data == 4) {
                    toastr.error("账号密码错误");
                } else if ((data ==5)){
                    toastr.error("验证码错误");
                }
            },
            error : function (e) {
                console.log(e);
                toastr.error("系统错误")
            }
        })
    }

    //图片点击事件
    function refreshCode(){
        //1.获取验证码图片对象
        var vcode = document.getElementById("vcode_login");

        //2.设置其src属性，加时间戳
        vcode.src = "${pageContext.request.contextPath}/loginController/checkCode?time="+new Date().getTime();
    }
</script>

<body>
<!--引入头部-->
<jsp:include page="header.jsp"/>
<!-- 头部 end -->
<section id="login_wrap">
    <div class="fullscreen-bg" style="background: url(../../images/login_bg.png);height: 532px;">

    </div>
    <div class="login-box">
        <div class="title">
            <img src="<%=path%>images/login_logo.png" alt="">
            <span>欢迎登录</span>
        </div>
        <div class="login_inner">

            <!--登录错误提示消息-->
<%--            <div id="errorMsg" class="alert alert-danger" ></div>--%>
            <form id="form_login" action="" method="post" accept-charset="utf-8">
                <input type="hidden" name="action" value="login"/>
                <input name="username" type="text" placeholder="请输入账号" autocomplete="off">
                <input name="password" type="text" placeholder="请输入密码" autocomplete="off">
                <div class="verify">
                    <input name="check" type="text" placeholder="请输入验证码" autocomplete="off">
                    <a href="javascript:refreshCode(this);" style="margin-left: 10px" >
                        <img src="${pageContext.request.contextPath}/loginController/checkCode" id="vcode_login" height="32px" alt="">
                    </a>

                </div>
                <div class="submit_btn">
                    <button type="button" onclick="userLogin()">登录</button>
                    <div class="auto_login">
                        <input type="checkbox" name="" class="checkbox">
                        <span>自动登录</span>
                    </div>
                </div>
            </form>
            <div class="reg">没有账户？<a href="${pageContext.request.contextPath}/pageController/toRegister">立即注册</a></div>
        </div>
    </div>
</section>
<!--引入尾部-->
<div id="footer">
    <jsp:include page="footer.jsp"/>
</div>
</body>
</html>
